home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxchrout.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.2 KB  |  63 lines

  1. /* Copyright (C) 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxchrout.c,v 1.2 2000/09/19 19:00:34 lpd Exp $ */
  20. #include "math_.h"
  21. #include "gx.h"
  22. #include "gxchrout.h"
  23. #include "gxfarith.h"
  24. #include "gxistate.h"
  25.  
  26. /*
  27.  * Determine the flatness for rendering a character in an outline font.
  28.  * This may be less than the flatness in the imager state.
  29.  * The second argument is the default scaling for the font: 0.001 for
  30.  * Type 1 fonts, 1.0 for TrueType fonts.
  31.  */
  32. double
  33. gs_char_flatness(const gs_imager_state *pis, floatp default_scale)
  34. {
  35.     /*
  36.      * Set the flatness to a value that is likely to produce reasonably
  37.      * good-looking curves, regardless of its current value in the
  38.      * graphics state.  If the character is very small, set the flatness
  39.      * to zero, which will produce very accurate curves.
  40.      */
  41.     double cxx = fabs(pis->ctm.xx), cyy = fabs(pis->ctm.yy);
  42.  
  43.     if (is_fzero(cxx) || (cyy < cxx && !is_fzero(cyy)))
  44.     cxx = cyy;
  45.     if (!is_xxyy(&pis->ctm)) {
  46.     double cxy = fabs(pis->ctm.xy), cyx = fabs(pis->ctm.yx);
  47.  
  48.     if (is_fzero(cxx) || (cxy < cxx && !is_fzero(cxy)))
  49.         cxx = cxy;
  50.     if (is_fzero(cxx) || (cyx < cxx && !is_fzero(cyx)))
  51.         cxx = cyx;
  52.     }
  53.     /* Correct for the default scaling. */
  54.     cxx *= 0.001 / default_scale;
  55.     /* Don't let the flatness be worse than the default. */
  56.     if (cxx > pis->flatness)
  57.     cxx = pis->flatness;
  58.     /* If the character is tiny, force accurate curves. */
  59.     if (cxx < 0.2)
  60.     cxx = 0;
  61.     return cxx;
  62. }
  63.